<html>
<head><meta charset="utf-8"><title>instance resolution for trait objects · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/instance.20resolution.20for.20trait.20objects.html">instance resolution for trait objects</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213540429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/instance%20resolution%20for%20trait%20objects/near/213540429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pmn <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/instance.20resolution.20for.20trait.20objects.html#213540429">(Oct 16 2020 at 10:01)</a>:</h4>
<p>Hi, </p>
<p>I'm trying to create a vtable for a trait implementation and get a panic when trying to call Instance::resolve on the defid and substs of a vtable method. <br>
I obtain the methods with tcx.vtable_methods. </p>
<p>The defid and substs look like: DefId(0:4 ~ shape[317d]::Shape[0]::area[0]), [&amp;ReErased Rectangle]<br>
for a concrete struct Rectangle, Trait Shape, and virtual method area. I need the instance to codegen the type. Do you have an idea why I can't resolve. <br>
The error stack trace is below. Thanks!</p>
<p>Error stack trace:<br>
thread 'rustc' panicked at 'no errors encountered even though <code>delay_span_bug</code> issued', src/librustc_errors/lib.rs:366:17<br>
stack backtrace:<br>
   0:        0x118a16f4b - &lt;std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display&gt;::fmt::h1fe5f5e7df1c06ce<br>
   1:        0x118abf3a4 - core::fmt::write::h50e4c8558042b93b<br>
   2:        0x118a44417 - std::io::Write::write_fmt::h3d8b15fbebd6c317<br>
   3:        0x118a16d65 - std::sys_common::backtrace::print::hcdcc563d239fc32e<br>
   4:        0x118a486dd - std::panicking::default_hook::{{closure}}::h69a16d7cd93470a5<br>
   5:        0x118a48500 - std::panicking::default_hook::h2323e99b20b3d4b3<br>
   6:        0x10e80ce14 - rustc_driver::report_ice::h1d5e42e55af10ab2<br>
   7:        0x118a48c73 - std::panicking::rust_panic_with_hook::hc7c97688eafcb812<br>
   8:        0x1130722ed - std::panicking::begin_panic::{{closure}}::hcd7ed8f980e936ee<br>
   9:        0x113072228 - std::sys_common::backtrace::__rust_end_short_backtrace::h3f2d34fa3bcf7267<br>
  10:        0x11398761e - std::panicking::begin_panic::h1f8c0f0f3d210c66<br>
  11:        0x113084766 - &lt;rustc_errors::HandlerInner as core::ops:<span aria-label="drop" class="emoji emoji-1f4a7" role="img" title="drop">:drop:</span>:Drop&gt;:<span aria-label="drop" class="emoji emoji-1f4a7" role="img" title="drop">:drop:</span>:h0e93b515716abf7c<br>
  12:        0x10e7d2a0d - core::ptr::drop_in_place::h5f2319d46c922ef7<br>
  13:        0x10e7d13c9 - core::ptr::drop_in_place::h572042487ac240ef<br>
  14:        0x10e7f965b - core::ptr::drop_in_place::he2b242eb541b979a<br>
  15:        0x10e7c6823 - core::ptr::drop_in_place::h2eaf67023721835d<br>
  16:        0x10e82ef21 - rustc_span::with_source_map::h3c4726ac5628ea89<br>
  17:        0x10e8446f2 - rustc_interface::interface::create_compiler_and_run::h8b9d081063aa7885<br>
  18:        0x10e803d19 - scoped_tls::ScopedKey&lt;T&gt;::set::h31f242ae718cdc15<br>
  19:        0x10e82f52c - rustc_span::with_session_globals::h1417134171319a25<br>
  20:        0x10e6f8ce7 - std::sys_common::backtrace::__rust_begin_short_backtrace::h366305b617813119<br>
  21:        0x10e848273 - std::panicking::try::hd24f7fead796c6c8<br>
  22:        0x10e6f4efc - core::ops::function::FnOnce::call_once{{vtable.shim}}::h3074074fea2852bf<br>
  23:        0x118a0d17b - &lt;alloc::boxed::Box&lt;F&gt; as core::ops::function::FnOnce&lt;A&gt;&gt;::call_once::hb2d3357b3ffe3ea4<br>
  24:        0x118a3f72a - std::sys::unix::thread::Thread:<span aria-label="new" class="emoji emoji-1f195" role="img" title="new">:new:</span>:thread_start::h994213843f09b983<br>
  25:     0x7fff71e8c109 - __pthread_start</p>



<a name="213540583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/instance%20resolution%20for%20trait%20objects/near/213540583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/instance.20resolution.20for.20trait.20objects.html#213540583">(Oct 16 2020 at 10:03)</a>:</h4>
<p>There should be a line above with the <code>delay_span_bug</code> message. What does it say?</p>



<a name="213540693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/instance%20resolution%20for%20trait%20objects/near/213540693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/instance.20resolution.20for.20trait.20objects.html#213540693">(Oct 16 2020 at 10:04)</a>:</h4>
<p>You should use <code>Instance::resolve_for_vtable</code> for vtable methods.</p>



<a name="213541629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/instance%20resolution%20for%20trait%20objects/near/213541629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pmn <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/instance.20resolution.20for.20trait.20objects.html#213541629">(Oct 16 2020 at 10:17)</a>:</h4>
<p>error: internal compiler error: Encountered error <code>Unimplemented</code> selecting <code>Binder(&lt;&amp;ReErased Rectangle as Shape&gt;)</code> during codegen</p>



<a name="213541706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/instance%20resolution%20for%20trait%20objects/near/213541706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pmn <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/instance.20resolution.20for.20trait.20objects.html#213541706">(Oct 16 2020 at 10:18)</a>:</h4>
<p>This is the error message, same with resolve_for_vtable</p>



<a name="213553450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/instance%20resolution%20for%20trait%20objects/near/213553450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pmn <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/instance.20resolution.20for.20trait.20objects.html#213553450">(Oct 16 2020 at 12:32)</a>:</h4>
<p>Do you have an idea of what's going wrong here?</p>



<a name="213553611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/instance%20resolution%20for%20trait%20objects/near/213553611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/instance.20resolution.20for.20trait.20objects.html#213553611">(Oct 16 2020 at 12:34)</a>:</h4>
<p>I don't know. <a href="https://github.com/bjorn3/rustc_codegen_cranelift/blob/0416f122aae296e7fa78cff64b5df683be1dfc2f/src/vtable.rs#L103-L121">https://github.com/bjorn3/rustc_codegen_cranelift/blob/0416f122aae296e7fa78cff64b5df683be1dfc2f/src/vtable.rs#L103-L121</a> works fine for me.</p>



<a name="213558191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/instance%20resolution%20for%20trait%20objects/near/213558191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pmn <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/instance.20resolution.20for.20trait.20objects.html#213558191">(Oct 16 2020 at 13:17)</a>:</h4>
<p>Actually I just noticed that it returns None for some reason even though def_id and substs are not empty...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>